package com.banma.web.controller;

import com.banma.common.entity.UserEntity;
import com.banma.service.impl.UserServiceImpl;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/user")
@Api(value = "用户管理模块",description = "用户相关接口")
public class UserContoller {
	
	private Logger logger = LoggerFactory.getLogger(UserContoller.class);
	@Autowired
	private UserServiceImpl userService;

	//@Autowired
	//private RedisTemplate<Object,Object> redisTemplate;

	//@Resource(name = "redisTemplate")
	//private ValueOperations<Object,Object> values;

	@RequestMapping(value = "/list" ,method =  RequestMethod.GET)
	@ApiOperation(value = "测试用户列表", notes = "用户列表接口")
	public List<UserEntity> queryAll(@ApiParam(value = "当前页", allowableValues = "range[1,10]", required = true, defaultValue = "1", allowMultiple = true)Integer page,
									 @ApiParam(value = "页大小", allowableValues = "range[5,20]", required = true, defaultValue = "1", allowMultiple = true)Integer size,HttpServletRequest request){
		PageHelper.startPage(1,5);
		logger.info(" -------- test ----------");
		List<UserEntity> userEntities = userService.queryAll();
	/*	Map<String,String> map = new HashMap<>();
		map.put("0001",JsonUtil.toJsonString(userService.queryAll()));
		map.put("0002","demo2");
		logger.info(JsonUtil.toJsonString(userService.queryAll()));
		values.set("map",map);*/
		return userEntities;
	}

	@RequestMapping(value = "detail",method = RequestMethod.POST)
	@ApiOperation(value = "用户详情接口", notes = "用户详情接口")

	public UserEntity detail(   UserEntity userEntity){

		return 	userService.findById(1);
	}

}
